package com.zang.im.croom.netty.decoder;

import com.google.protobuf.MessageLite;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;

import java.util.List;

import static io.netty.buffer.Unpooled.wrappedBuffer;

/**
 * 编码 Proto 转 Json
 * @author Zhang Qiang
 * @Date 2019/7/29 16:14
 */
public class EnCoder extends MessageToMessageEncoder<MessageLite> {

//    @Override
//    protected void encode(ChannelHandlerContext ctx, MessageLite msg, ByteBuf out) throws Exception {
//        byte[] body = msg.toByteArray();
//        byte[] header = encodeHeader(msg, (short)body.length);
//
//
//    }
    private byte[] encodeHeader(MessageLite msg, int value) {
        byte[] b = new byte[4];

        return b;

    }

    @Override
    protected void encode(ChannelHandlerContext ctx, MessageLite msg, List<Object> out) throws Exception {
        ByteBuf result = null;
        result = wrappedBuffer(msg.toByteArray());


    }
}
